package com.web.kdl.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zhangQi
 * @date 2022/5/26 - 14:37
 * 站点及飞轮设备故障状态判断
 */
public class ErrorStatusUtils {
    
    // 站点系统故障判断
    public String[] sysErrorUtil(int fid) {
        // 系统故障
        String[] sysErrorInfos = new String[3];
        switch (fid) {
            case 1:
                sysErrorInfos[0] = "系统控制单元上电自检故障";
                sysErrorInfos[1] = "重要";
                sysErrorInfos[2] = "停机";
                break;
            case 2:
                sysErrorInfos[0] = "24V过压故障";
                sysErrorInfos[1] = "重要";
                sysErrorInfos[2] = "停机";
                break;
            case 3:
                sysErrorInfos[0] = "24V欠压故障";
                sysErrorInfos[1] = "重要";
                sysErrorInfos[2] = "停机";
                break;
            case 4:
                sysErrorInfos[0] = "5V过压故障";
                sysErrorInfos[1] = "重要";
                sysErrorInfos[2] = "停机";
                break;
            case 5:
                sysErrorInfos[0] = "5V欠压故障";
                sysErrorInfos[1] = "重要";
                sysErrorInfos[2] = "停机";
                break;
            case 6:
                sysErrorInfos[0] = "KM1反馈状态异常故障";
                sysErrorInfos[1] = "重要";
                sysErrorInfos[2] = "停机";
                break;
            case 7:
                sysErrorInfos[0] = "KM2反馈状态异常故障";
                sysErrorInfos[1] = "重要";
                sysErrorInfos[2] = "停机";
                break;
            case 8:
                sysErrorInfos[0] = "KM3反馈状态异常故障";
                sysErrorInfos[1] = "重要";
                sysErrorInfos[2] = "停机";
                break;
            case 9:
                sysErrorInfos[0] = "KM4反馈状态异常故障";
                sysErrorInfos[1] = "重要";
                sysErrorInfos[2] = "停机";
                break;
            case 10:
                sysErrorInfos[0] = "FU1故障";
                sysErrorInfos[1] = "重要";
                sysErrorInfos[2] = "停机";
                break;
            case 11:
                sysErrorInfos[0] = "FU2故障";
                sysErrorInfos[1] = "重要";
                sysErrorInfos[2] = "停机";
                break;
            case 12:
                sysErrorInfos[0] = "FU3故障";
                sysErrorInfos[1] = "重要";
                sysErrorInfos[2] = "停机";
                break;
            case 13:
                sysErrorInfos[0] = "FU4故障";
                sysErrorInfos[1] = "重要";
                sysErrorInfos[2] = "停机";
                break;
            case 14:
                sysErrorInfos[0] = "FU5故障";
                sysErrorInfos[1] = "重要";
                sysErrorInfos[2] = "停机";
                break;
            case 15:
                sysErrorInfos[0] = "绝缘检测仪故障";
                sysErrorInfos[1] = "重要";
                sysErrorInfos[2] = "停机";
                break;
            case 16:
                sysErrorInfos[0] = "SCU与MCU通信故障";
                sysErrorInfos[1] = "重要";
                sysErrorInfos[2] = "停机";
                break;
            case 17:
                sysErrorInfos[0] = "SCU与UMB通信故障";
                sysErrorInfos[1] = "重要";
                sysErrorInfos[2] = "停机";
                break;
            default:
                break;
        }
        return sysErrorInfos;
    }

    //电机控制器_设备故障判断
    public String[] dianJiErrorUtil(int fid) {
        // 电机控制器故障
        String[] dianJiInfos = new String[3];
        switch (fid) {
            case 1:
                dianJiInfos[0] = "电机控制器温度无效故障";
                dianJiInfos[1] = "普通";
                dianJiInfos[2] = "显示";
                break;
            case 2:
                dianJiInfos[0] = "电机温度无效故障";
                dianJiInfos[1] = "紧急";
                dianJiInfos[2] = "降功率";
                break;
            case 3:
                dianJiInfos[0] = "电机其它故障";
                dianJiInfos[1] = "重要";
                dianJiInfos[2] = "停机";
                break;
            default:
                break;
        }
        return dianJiInfos;
    }

    // 飞轮本体设备故障判断
    public String[] flyErrorUtil(int fid) {
        // 飞轮故障
        String[] flyErrorInfos = new String[3];
        switch (fid) {
            case 1:
                flyErrorInfos[0] = "上轴承外圈温度无效故障";
                flyErrorInfos[1] = "重要";
                flyErrorInfos[2] = "停机";
                break;
            case 2:
                flyErrorInfos[0] = "上轴承外圈温度过温告警";
                flyErrorInfos[1] = "紧急";
                flyErrorInfos[2] = "降功率";
                break;
            case 3:
                flyErrorInfos[0] = "上轴承外圈温度过温故障";
                flyErrorInfos[1] = "重要";
                flyErrorInfos[2] = "停机";
                break;
            case 4:
                flyErrorInfos[0] = "下轴承外圈温度无效故障";
                flyErrorInfos[1] = "重要";
                flyErrorInfos[2] = "停机";
                break;
            case 5:
                flyErrorInfos[0] = "下轴承外圈温度过温告警";
                flyErrorInfos[1] = "紧急";
                flyErrorInfos[2] = "降功率";
                break;
            case 6:
                flyErrorInfos[0] = "下轴承外圈温度过温故障";
                flyErrorInfos[1] = "重要";
                flyErrorInfos[2] = "停机";
                break;
            case 7:
                flyErrorInfos[0] = "电机转子过温告警";
                flyErrorInfos[1] = "紧急";
                flyErrorInfos[2] = "降功率";
                break;
            case 8:
                flyErrorInfos[0] = "电机转子过温故障";
                flyErrorInfos[1] = "重要";
                flyErrorInfos[2] = "停机";
                break;
            case 9:
                flyErrorInfos[0] = "力传感器无效故障";
                flyErrorInfos[1] = "重要";
                flyErrorInfos[2] = "停机";
                break;
            case 10:
                flyErrorInfos[0] = "力传感器承载欠载故障";
                flyErrorInfos[1] = "重要";
                flyErrorInfos[2] = "停机";
                break;
            case 11:
                flyErrorInfos[0] = "力传感器485通信故障";
                flyErrorInfos[1] = "重要";
                flyErrorInfos[2] = "停机";
                break;
            case 12:
                flyErrorInfos[0] = "真空泄漏故障";
                flyErrorInfos[1] = "重要";
                flyErrorInfos[2] = "停机";
                break;
            case 13:
                flyErrorInfos[0] = "飞轮轴向1位移断线故障";
                flyErrorInfos[1] = "重要";
                flyErrorInfos[2] = "停机";
                break;
            case 14:
                flyErrorInfos[0] = "飞轮轴向1位移超限故障";
                flyErrorInfos[1] = "重要";
                flyErrorInfos[2] = "停机";
                break;
            case 15:
                flyErrorInfos[0] = "飞轮轴向2位移断线故障";
                flyErrorInfos[1] = "重要";
                flyErrorInfos[2] = "停机";
                break;
            case 16:
                flyErrorInfos[0] = "飞轮轴向2位移超限故障";
                flyErrorInfos[1] = "重要";
                flyErrorInfos[2] = "停机";
                break;
            case 17:
                flyErrorInfos[0] = "飞轮纵向加速度超限故障";
                flyErrorInfos[1] = "重要";
                flyErrorInfos[2] = "停机";
                break;
            case 18:
                flyErrorInfos[0] = "飞轮上端横向加速度超限故障";
                flyErrorInfos[1] = "重要";
                flyErrorInfos[2] = "停机";
                break;
            case 19:
                flyErrorInfos[0] = "飞轮下端横向加速度超限故障";
                flyErrorInfos[1] = "重要";
                flyErrorInfos[2] = "停机";
                break;
            default:
                break;
        }
        return flyErrorInfos;
    }

    // 卸载轴承控制器故障判断
    public String[] zCErrorUtil(int fid) {
        // 轴承故障
        String[] zcErrorInfos = new String[3];
        switch (fid) {
            case 1:
                zcErrorInfos[0] = "卸载轴承控制器过温故障";
                zcErrorInfos[1] = "重要";
                zcErrorInfos[2] = "停机";
                break;
            case 2:
                zcErrorInfos[0] = "磁轴承线圈温度传感器断线故障";
                zcErrorInfos[1] = "普通";
                zcErrorInfos[2] = "显示";
                break;
            case 3:
                zcErrorInfos[0] = "磁轴承线圈过温故障";
                zcErrorInfos[1] = "重要";
                zcErrorInfos[2] = "停机";
                break;
            case 4:
                zcErrorInfos[0] = "卸载轴承控制器母线过压故障";
                zcErrorInfos[1] = "重要";
                zcErrorInfos[2] = "停机";
                break;
            case 5:
                zcErrorInfos[0] = "卸载轴承控制器母线欠压故障";
                zcErrorInfos[1] = "重要";
                zcErrorInfos[2] = "停机";
                break;
            case 6:
                zcErrorInfos[0] = "磁轴承线圈过流故障";
                zcErrorInfos[1] = "重要";
                zcErrorInfos[2] = "停机";
                break;
            default:
                System.out.println("default");
                break;
        }
        return zcErrorInfos;
    }

    // 冷却设备故障判断
    // 暂时没用到
    public String[] lQErrorUtil(int fid) {
        // 冷水机故障
        String[] lQErrorInfos = new String[3];
        lQErrorInfos[0] = "冷水机故障";
        lQErrorInfos[1] = "重要";
        lQErrorInfos[2] = "停机";
        return lQErrorInfos;
    }

    //飞轮工作状态统计 0-2待机 3-4运行 5告警
    public Map flyWorkStatusCountUtil(List<Integer> fids){
        Map<String, Object> map = new HashMap<String, Object>();
        int SysDown = 0; // 待机
        int SysNorm = 0; // 运行
        int SysFail = 0; // 告警
        for(int i=0; i < fids.size(); i++) {
            if(fids.get(i) <= 2) {
                SysDown = SysDown +1;
            } else if (fids.get(i) == 3 || fids.get(i) == 4) {
                SysNorm = SysNorm +1;
            } else if (fids.get(i) == 5) {
                SysFail = SysFail +1;
            }
        }
        map.put("SysDown", SysDown);
        map.put("SysNorm", SysNorm);
        map.put("SysFail", SysFail);
        return map;
    }

    //站点3飞轮工作状态统计 0-2待机 3-4运行 5告警，每次只判断一个 所以区别与第一个站点
    public Map flyWorkStatusCountUtil3(int fid){
        Map<String, Object> map = new HashMap<String, Object>();
        int SysDown = 0; // 待机
        int SysNorm = 0; // 运行
        int SysFail = 0; // 告警

        if(fid <= 2) {
            SysDown = SysDown +1;
        } else if (fid == 3 || fid == 4) {
            SysNorm = SysNorm +1;
        } else if (fid == 5) {
            SysFail = SysFail +1;
        }
        map.put("SysDown", SysDown);
        map.put("SysNorm", SysNorm);
        map.put("SysFail", SysFail);
        return map;
    }
    /**
     * 分站点页拓扑图工作状态判断方法
     * 0：下电，1：初始化完成，2：维持，3：充电，4：放电，5，故障停机
     */
    public String flyWorkStatusUtil(int statusCode){
        String flywheelWorStaF = null;
        switch (statusCode) {
            case 0:
                flywheelWorStaF = "下电";
                break;
            case 1:
                flywheelWorStaF = "初始化完成";
                break;
            case 2:
                flywheelWorStaF = "维持";
                break;
            case 3:
                flywheelWorStaF = "充电";
                break;
            case 4:
                flywheelWorStaF = "放电";
                break;
            case 5:
                flywheelWorStaF = "故障停机";
                break;
            default:
                break;
        }
        return flywheelWorStaF;
    }
}
